import requests

host = 'http://10.0.0.18:8080'
session = requests.session


def query():
    # 查询余额
    url = host + '/pinter/bank/api/query'  # 接口地址
    params = {
        'userName': 'admin'
    }

    resp = session.request(url=url, method='get', params=params)

    status_code = resp.status_code  # 获取响应状态码
    print('响应状态码：{}'.format(status_code))

    text = resp.text  # 获取响应内容，结果类型是字符串
    print('响应内容：{}'.format(text))


def login():
    # 登录
    url = host + '/pinter/bank/api/login'
    # 表单参数
    data = {
        'userName': 'admin',
        'password': '1234'
    }
    session.request(url=url, method='post', data=data)


if __name__ == '__main__':
    login()
    query()
